<?php

namespace App\Http\Api\Controllers;

use App\Http\Controllers\Controller;
use App\Lib\Upload\Image;
use App\Lib\Upload\UploadHandle;
use Illuminate\Http\Request;


class UploadController extends Controller
{


    /*
     * 图片上传
     * */
    public function store(Request $request)
    {
        $file = $request->file;
        $type = $request->input('type') ?? 'Image';
        $dir = $request->input('dir') ?? 'products';
        $result = UploadHandle::factory($type,$file,$type,$dir)->upload();
        return res('上传成功', $result);
    }

    /*
     * base64图片上传
     * */
    public function bsUpload(Request $request)
    {
        $file = $request->input('file');
        $type = 'Image';
        $dir = $request->input('dir') ?? 'products';
        $result = UploadHandle::factory($type,$file,$type,$dir)->bsUpload();
        return res('上传成功', $result);
    }

}
